package com.itheima.behaviour.controller;
import com.itheima.behaviour.pojo.ApBehaviorEntry;
import com.itheima.behaviour.service.ApBehaviorEntryService;
import com.itheima.common.pojo.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.itheima.core.controller.AbstractCoreController;

/**
* <p>
* APP行为实体表,一个行为实体可能是用户或者设备，或者其它 控制器</p>
* @author 作者
* @since 2021-08-30
*/
@RestController
@RequestMapping("/apBehaviorEntry")
public class ApBehaviorEntryController extends AbstractCoreController<ApBehaviorEntry> {

    private ApBehaviorEntryService apBehaviorEntryService;

    //注入
    @Autowired
    public ApBehaviorEntryController(ApBehaviorEntryService apBehaviorEntryService) {
        super(apBehaviorEntryService);
        this.apBehaviorEntryService=apBehaviorEntryService;
    }

    /**
     * 根据ID（设备机器号|userId）查询用户信息（游客、系统会员）
     */
    @PostMapping(value = "/entry")
    public Result<ApBehaviorEntry> getByEquipmentIdOrUserId(@RequestParam(required = false) Integer equipmentId,@RequestParam(required = false) Integer userId){
        ApBehaviorEntry entry = apBehaviorEntryService.getByEquipmentIdOrUserId(equipmentId,userId);
        return Result.ok(entry);
    }

}

